package com.mflex.shelflocationquery.adapter;

import android.app.Activity;
import android.graphics.Color;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.mflex.shelflocationquery.R;
import com.mflex.shelflocationquery.model.ScsTxnList;

import java.util.List;


public class TxnListAdapter extends BaseAdapter {
    List<String> items;
    Activity context;

    public TxnListAdapter(Activity context, List<String> items) {
        this.context = context;
        this.items = items;
    }

    @Override
    public int getCount() {
        return items.size();
    }

    @Override
    public Object getItem(int position) {
        return items.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        String item = items.get(position);
        View view = convertView;
        view = context.getLayoutInflater().inflate(R.layout.item_txn_list, null);
//        ViewHolder = new ViewHolder();
        ((TextView) view.findViewById(R.id.txtPanel)).setText(item);

        if (position % 2 == 0) {
            ((LinearLayout) view.findViewById(R.id.txtTxnList)).setBackgroundColor(Color.rgb(221, 221, 221));
        }
        return view;
    }
}